import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ProjectUserVO, ProjectUserForm, ProjectUserQuery } from '@/api/workorder/projectUser/types';

/**
 * 查询项目关联人员列表
 * @param query
 * @returns {*}
 */

export const listProjectUser = (query?: ProjectUserQuery): AxiosPromise<ProjectUserVO[]> => {
  return request({
    url: '/workorder/projectUser/list',
    method: 'get',
    params: query
  });
};

export const queryProjectUserListByProjectId = (projectId: string) => {
  return request({
    url: '/workorder/projectUser/queryProjectUserListByProjectId',
    method: 'get',
    params: {projectId:projectId}
  });
};

/**
 * 查询项目关联人员详细
 * @param projectId
 */
export const getProjectUser = (projectId: string | number): AxiosPromise<ProjectUserVO> => {
  return request({
    url: '/workorder/projectUser/' + projectId,
    method: 'get'
  });
};

/**
 * 新增项目关联人员
 * @param data
 */
export const addProjectUser = (data: ProjectUserForm) => {
  return request({
    url: '/workorder/projectUser',
    method: 'post',
    data: data
  });
};

/**
 * 修改项目关联人员
 * @param data
 */
export const updateProjectUser = (data: ProjectUserForm) => {
  return request({
    url: '/workorder/projectUser',
    method: 'put',
    data: data
  });
};

/**
 * 删除项目关联人员
 * @param projectId
 */
export const delProjectUser = (projectId: string | number | Array<string | number>) => {
  return request({
    url: '/workorder/projectUser/' + projectId,
    method: 'delete'
  });
};
